package com.woniuxy.service;

import com.woniuxy.domain.Product;
import com.woniuxy.service.impl.ProductServiceFallbackFactory;
import com.woniuxy.util.ResultVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
//注意，fallback和fallbackFactory只能使用其中一个。
@Primary
@FeignClient(value = "product-service", fallbackFactory = ProductServiceFallbackFactory.class)
public interface IProductService {

    @GetMapping("products/{id}")
    public ResultVO findById(@PathVariable("id") Integer id);

    @PutMapping("products")
    public ResultVO reduceProductStock(Product product);

    @PostMapping("products")
    public ResultVO addProduct(Product product);

    @GetMapping("/products/testloadbalance")
    public ResultVO testLoadBalance();
}
